package com.jph.scan.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.jph.scan.R;
import com.jph.scan.zxing.ScanManager;

/**
 * 扫描应用实例<br/>
 * 在onCreate、onResume、onPause、onDestroy<br/>
 * 方法中调用ScanManager的对应方法
 * @author JPH
 * @Date 2016-5-9 下午6:15:33
 */
public final class CaptureActivity extends Activity implements ScanManager.OnScanResultListener{

	private ScanManager scanManager;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_capture);
		scanManager=new ScanManager(this,this);
		scanManager.onCreate(savedInstanceState);
	}
	public void onClick(View view){
		switch (view.getId()){
			case R.id.btnPause:
				scanManager.onPause();
				break;
			case R.id.btnContinue:
				scanManager.onResume();
				break;
		}
	}
	@Override
	public void onScanResult(String result) {
		Toast.makeText(this,result,Toast.LENGTH_LONG).show();
	}
	@Override
	protected void onResume() {
		super.onResume();
		scanManager.onResume();
	}
	@Override
	protected void onPause() {
		scanManager.onPause();
		super.onPause();
	}
	@Override
	protected void onDestroy() {
		scanManager.onDestroy();
		super.onDestroy();
	}
}